using System.Windows;
using System.Windows.Controls;
using SProject;

namespace ProjectView.Windows
{
	internal class DataGridCellEditSelector : DataTemplateSelector
	{
		public DataTemplate Template { get; set; }

		public override DataTemplate SelectTemplate(object item, DependencyObject container)
		{
			FrameworkElement frameworkElement = container as FrameworkElement;
			CustomSampleType customSampleType = ((container as ContentPresenter).Parent as DataGridCell).DataContext as CustomSampleType;
			if (customSampleType == null || !customSampleType.CanEditor)
			{
				return Template;
			}
			return frameworkElement.FindResource("dataTemplateSampleTypeName") as DataTemplate;
		}
	}
}
